package com.jht.pj.sys.service.impl;

import com.jht.pj.common.exception.ServiceException;
import com.jht.pj.sys.dao.SingerDao;
import com.jht.pj.sys.dao.SingerSongDao;
import com.jht.pj.sys.dao.SongDao;
import com.jht.pj.sys.pojo.Singer;
import com.jht.pj.sys.pojo.SingerSong;
import com.jht.pj.sys.pojo.Song;
import com.jht.pj.sys.service.SingerSongService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class SingerSongServiceImpl implements SingerSongService {

    @Autowired
    private SingerSongDao singerSongDao;
    @Autowired
    private SingerDao singerDao;
    @Autowired
    private SongDao songDao;

    @Override
    public List<SingerSong> findAll(String name) {
        List<SingerSong> list = singerSongDao.findAll(name);
        return list;
        /*int singerId = singerDao.findSingerIdByName(name);
        System.out.println(singerId);
        if(singerId==0) {
            List<SingerSong> list = singerSongDao.findAll(name);
        }else {
            //List<SingerSong> list = singerSongDao.findTwo(name, singerId);
            System.out.println("text");
        }
        return null;*/
    }

    @Override
    public int saveSong(Song entity, String singerName) {
        int singerId = singerDao.findSingerIdByName(singerName);
        entity.setSingerId(singerId);
        int rows = singerSongDao.insertSong(entity);
        return rows;
    }
}
